//商品获取信息接口
import request from "@/utils/request";
//引入类型
import type { TardeMarkData, TardeMark } from "./type";
enum API {
  API_GET_PRODUCT_INFO = "/admin/product/baseTrademark/",
  ADD_TRADE_MARK_URL = "/admin/product/baseTrademark/save",
  UPDATE_TRADE_MARK_URL = "/admin/product/baseTrademark/update",
  DELETE_URL = "/admin/product/baseTrademark/remove/",
}
//获取产品信息接口
export const getProDuctInfo = (page: number, limit: number) =>
  request.get<any, TardeMarkData>(
    API.API_GET_PRODUCT_INFO + `${page}/${limit}`,
  );
//由于修改和新增十分类似，所以将两个接口封装到一个函数里
export const addOrUpdateTradeMark = (data: TardeMark) => {
  //有id就是修改，没有id便是新增
  if (data.id) {
    return request.put<any, any>(API.UPDATE_TRADE_MARK_URL, data);
  } else {
    return request.post<any, any>(API.ADD_TRADE_MARK_URL, data);
  }
};
//删除产品接口
export const deleteTradeMark = (id: number) =>
  request.delete<any, any>(API.DELETE_URL + id);
